`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    10:18:22 10/18/2012 
// Design Name: 
// Module Name:    debouncer 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module debouncer(
    reset_i,
	 up_i,
	 down_i,
	 startgame_i,
	 clk_i,
    reset_o,
	 up_o,
	 down_o,
	 startgame_o
    );
	 
	input reset_i,clk_i,up_i,down_i,startgame_i; //definicion de variables de entrada y salida
	output reset_o,up_o,down_o,startgame_o;
	 
	reg reset_o,resflip1,resflip2,up_o,upflip1,upflip2,down_o,downflip1,downflip2,startgame_o,startflip1,startflip2;
	 
	initial begin 						//inicializacion de variables	
		reset_o=0;
		resflip1=0;
		resflip2=0;
		up_o=0;
		upflip1=0;
		upflip2=0;
		down_o=0;
		downflip1=0;
		downflip2=0;
		startgame_o=0;
		startflip1=0;
		startflip2=0;
	end
	 
	always@(posedge clk_i) begin 			//	flip flops de sincronizacion de las variables
		resflip1<=reset_i;
		resflip2<=resflip1;
		reset_o<=resflip2;
		upflip1<=up_i;
		upflip2<=upflip1;
		up_o<=upflip2;
		downflip1<=down_i;
		downflip2<=downflip1;
		down_o<=downflip2;
		startflip1<=startgame_i;
		startflip2<=startflip1;
		startgame_o<=startflip2;
	end
		 
	 
	 




endmodule
